$(document).ready(function() {
    activityManageRecycle.init();

});
var _mmg = null;
var editIndex = undefined;
var activityManageRecycle = function(){
    return{
        init: function () {
            _mmg = $('#dg').datagrid({
                url: '/marketing/activityManageRecyclePage',
                method: 'post',
                rownumbers: true,
                striped: true,
                nowrap: true,
                pageList: [25, 30, 35],
                idField: 'id', //主键
                onClickRow: 'onClickRow',
                columns: [
                    [
                        {field: 'ck', checkbox: true},
                        {field: 'id', title: 'id', hidden: true},
                        {field: 'AcTitle', title: '标题', width: 300},
                        {field: 'CreateTime', title: '发布时间', width: 150},
                        {field: 'AcTime', title: '活动时间', width: 160},
                        {field: 'AcPlace', title: '活动地点', width: 130},
                        {field: 'AcNumber', title: '活动名额/人', width: 100},
                        {field: 'AcObject', title: '活动对象', width: 150},
                        {
                             field: 'operation',
                             title: '操作',
                             width: 100,
                             type: 'String',
                             formatter: function (val, item, rowIndex) {
                                      return '<span><a href="#" onclick="activityManageRecycle.reduction(\''+ item.Id +'\')"><span style="color:blue;">还原</span></a></span> &nbsp;   <span><a href="#" onclick="activityManageRecycle.delete(\''+ item.Id +'\')"><span style="color:blue;">删除</span></a></span>';
                             }
                             },
                    ]
                ],


            }).datagrid("clientPaging");
        },


        //从回收站还原数据
        reduction: function (Id) {
            $.messager.confirm('确认', '确定要还原数据？', function (r) {
                if (r) {
                        $.ajax({
                            type: 'POST',
                            url: '/marketing/redactivitybyid',
                            data: 'Id=' + Id,
                            success: function (result) {
                                if (result['info'] == '1') {
                                    alert("还原成功")
                                    window.location.reload();
                                    return;
                                } else {
                                    alert('还原失败！');
                                    return;
                                }
                            }
                        })
                }
            });


        },

        //从回收站删除数据
        delete: function (Id) {
            $.messager.confirm('确认', '确定要删除数据？', function (r) {
                if (r) {
                    $.ajax({
                        type: 'POST',
                        url: '/marketing/delactivitybyid',
                        data: 'Id=' + Id,
                        success: function (result) {
                            if (result['info'] == '1') {
                                alert("删除成功")
                                window.location.reload();
                                return;
                            } else {
                                alert('删除失败！');
                                return;
                            }
                        }
                    })
                }
            });


        },


    }

}
();

